<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/3/2
 * Time: 11:27
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\TrainContentLogic;
use App\Http\Traits\TrainContentTrait;
use App\Http\Controllers\BaseController;
class TrainContentController extends BaseController
{
    use TrainContentTrait;


    /**
     * @SWG\POST(
     *     path="/trainContent/update",
     *     tags={"TrainContent"},
     *     description="更新培训内容",
     *     operationId="updateTrainContent",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="train_id",
     *         in="query",
     *         description="培训ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="content_str",
     *         in="query",
     *         description="内容JSON字符串",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateTrainContent()
    {
        $train_id = $this->id;
        $content_str = $this->content_str;
        $data = [
            'train_id' => $train_id,
            'content_str' => $content_str
        ];
        $response = TrainContentLogic::updateTrainContent($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\GET(
     *     path="/trainContent/detail",
     *     tags={"TrainContent"},
     *     description="培训内容详情",
     *     operationId="getTrainContentDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="train_id",
     *         in="query",
     *         description="培训ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getTrainContentDetail()
    {
        $train_id = $this->train_id;
        $data = [
            'train_id' => $train_id
        ];
        $response = TrainContentLogic::getTrainContentDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}